Entering code within the C-block or C++-block (deprecated)

How to enter the C-code or C++-code in your →blocks and use them within →ST:

  1. As preparation, set the correct build configuration: context menu of the project, select Build ConfigurationsSet Active and the command for the corresponding platform
    (info) Without this preparation you will not be able to use the Neuron Power Engineer functions to navigate within the libraries to be used.

  2. Double-click the file LCfu___name.c or LCfu___name.cpp displayed in the project explorer.This file has automatically been created by Neuron Power Engineer, when you have created the interface for the C-block or the C++-block.

  3. In the opened file, enter the required C-code or C++-code.
    Use a This Pointer for accessing variables as well as in-/outputs (for function blocks) or outputs (for functions) that you have declared for the interface. Enter all names in upper-case letters.
    For functions, the access to inputs is done without using a This Pointer.

    Example for accessing input/output of the function block

    #define V(VAR) (LC_this->LC_VD_##VAR)  /* C-macro for a simplified access to parameter */
       /* ... */
    V(OUT) = V(IN1) + V(IN2);              /* your C-code within the C-file for the function block */
    Example for accessing input/output of the function
    #define V(VAR) (LC_this->LC_VD_##VAR)  /* C-macro for a simplified access to parameter */
       /* ... */
    V(OUT) = LC_VD_IN1 + LC_VD_IN2;        /* your C-code within the C-file for the function */
    V(MYCFUN) = LC_VD_IN1 + 1;

    Restriction for C-blocks

  4. Save the file with your C-code or C++-code.
  5. Repeat the steps for each file in which you want to enter C-code or C++-code.

  6. Use the function blocks and functions within your application (e.g. with the →program that has been declared within an ST-object without {extern_c} or {extern_cxx}):

    1. Required only for function blocks: Declare the required →function block instances. The necessary syntax is listed under: "Declaration of function block instances in ST"

    2. Required for function blocks and functions: Enter the calls of the blocks. The necessary syntax is listed under: "Calls in ST"

  7. Save the ST-object with your application.

If you load the application onto the PLC now, the defined code of the C-block or C++-block is included.